package set;

import java.util.HashSet;
import java.util.Set;

public class Sets {

	
	public static<T> Set<T> union(Set<T> a,Set<T> b){
		Set<T> result=new HashSet<T>(a);
		result.addAll(b);
		return result;
	}
	
	//获取交集
	public static<T> Set<T> intersection(Set<T> a,Set<T> b){
		Set<T> result=new HashSet<T>(a);
		result.retainAll(b);
		return result;
	}
	
	//获取不同数据
	public static<T> Set<T> difference(Set<T> a,Set<T> b){
		Set<T> re=new HashSet<T>(a);
		re.removeAll(b);
		return re;
	}
	
	//获取完全数据
	public static<T> Set<T> complent(Set<T> a,Set<T> b){
		return difference(union(a,b),intersection(a,b));
	}
	
}
